﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace TS2000Control
{
    public class RadioConfigSection : ConfigurationSection
    {
        [ConfigurationProperty("Radios")]
        public RadioCollection Radios 
        {
            get { return ((RadioCollection)(base["Radios"])); }
        }
    }

    public class RadioCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new Radio();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((Radio)element).Name;
        }

        public Radio this[int idx]
        {
            get
            {
                return (Radio)BaseGet(idx);
            }
        }
    }

    public class Radio : ConfigurationElement
    {
        [ConfigurationProperty("name", IsKey=true, IsRequired = true)]
        public string Name
        {
            get { return ((string)(base["name"])); }
            set { base["name"] = value; }
        }

        [ConfigurationProperty("port", IsRequired = true)]
        public string Port
        {
            get { return ((string)(base["port"])); }
            set { base["port"] = value; }
        }

        [ConfigurationProperty("baud", IsRequired = true)]
        public string Baud
        {
            get { return ((string)(base["baud"])); }
            set { base["baud"] = value; }
        }

        [ConfigurationProperty("active", IsRequired = true)]
        public string Active
        {
            get { return ((string)(base["active"])); }
            set { base["active"] = value; }
        }
    }
}
